package com.epam.javalab.giorgadze.task2.entity;

import java.util.ArrayList;
import java.util.List;

public class Word implements SentencePart<Symbol>, Cloneable {
    private List<Symbol> symbolList = new ArrayList<Symbol>();

    public List<Symbol> getSymbolList() {
        return symbolList;
    }

    public void setSymbolList(List<Symbol> symbolList) {
        this.symbolList = symbolList;
    }

    public Word(List<Symbol> symbolList) {
        this.symbolList = symbolList;
    }

    public Word() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Word word = (Word) o;

        if (symbolList != null ? !symbolList.equals(word.symbolList) : word.symbolList != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return symbolList != null ? symbolList.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "\n" + symbolList;
    }

    @Override
    public void add(Symbol element) {
        symbolList.add(element);
    }

    @Override
    public void remove(Symbol element) {
        symbolList.remove(element);
    }

    public Word clone() {
        Word word = new Word(this.symbolList);
        return word;
    }
}
